-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[web] Add _flow.js for component tests. #2342
Conversation
test/mitmproxy/tools/web/test_app.py
Outdated
tflow_json = _json.dumps( | ||
app.flow_to_json(tflow.tflow(resp=True, err=True)), indent=4, sort_keys=True | ||
) | ||
web_root = os.path.join(os.getcwd(), 'web') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cwd
is a bit dangerous as this may change depending on where you execute your tests. Use this and construct the path relative from here. :)
@@ -1,101 +1,101 @@ | |||
import React from 'react' | |||
import renderer from 'react-test-renderer' | |||
import * as Columns from '../../../components/FlowTable/FlowColumns' | |||
import { TFlow } from '../../ducks/tutils' | |||
import _tflow from '../../ducks/_tflow' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to have tflow
as a "public" module or do we want to integrate it in tutils
? I was thinking of the following in tutils:
export {default as TFlow} from './_tflow'
Both really works, go with what you prefer. 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a really good point! I would like to integrate all the test mock object into tutils.js
web/src/js/__tests__/ducks/_tflow.js
Outdated
@@ -8,7 +8,7 @@ export default function(){ | |||
"alpn_proto_negotiated": "http/1.1", | |||
"cipher_name": "cipher", | |||
"clientcert": null, | |||
"id": "75bfd3cd-a084-4d84-a063-b0804dc91342", | |||
"id": "4a18d1a0-50a1-48dd-9aa6-d45d74282939", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, this commit is helpful in unintended ways. We need to set the ids and timestamps to constant values before exporting, otherwise this file will always be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll check if there is any other value would be changed from time to time, and give a constant value in the Python test.
👍 👍 👍 |
Suggested by @mhils here, we add a python test to generate
js/__tests__/ducks/_flow.js
for the components tests. In this way, each time when we run the python test, it will produce a generator function for our js tests.